//取文件后缀名
function getFileExt(filepath)
{
    if (filepath != "") {
        var pos = filepath.replace(/.+\./, "");
        return pos;
    }
    return '';
}
//取文件名不带后缀
function getFileNameNoExt(filepath)
{
	var arr = filepath.split('.');
	return arr[0];
}

function in_array(needle, haystack) {
	if(typeof needle == 'string' || typeof needle == 'number') {
	  	for(var i in haystack) {
	   		if(haystack[i] == needle) {
	     		return true;
	   		}
		}
	}
	return false;
}

String.prototype.replaceAll = function(s1,s2) { 
    /*var str = this;
	while (str.indexOf(s1) != -1) {
		str = str.replace(s1, s2);
	}
	return str;*/
	
	s1 = s1.replace(/(\[)/g, "\\[");
	s1 = s1.replace(/(\])/g, "\\]");
	s1 = s1.replace(/(\()/g, "\\(");
	s1 = s1.replace(/(\))/g, "\\)");
	s1 = s1.replace(/(\*)/g, "\\*");
	
	var ret=  this.replace(new RegExp(s1, 'gm'),s2);
	return ret;
}

Array.prototype.hasVal = function(e) { 
    for(i=0; i<this.length; i++){
        if(this[i] == e){
			return true;
		}
    }
    return false;
}

String.prototype.trim = function() 
{ 
	return this.replace(/(^\s*)|(\s*$)/g, ""); 
} 
String.prototype.lTrim = function() 
{ 
	return this.replace(/(^\s*)/g, ""); 
} 
String.prototype.rTrim = function() 
{ 
	return this.replace(/(\s*$)/g, ""); 
} 


$.extend($.prototype, {
	htmlCode:function(){
		var div = $('<div />');
		$(this).clone().appendTo(div);
		return div.html();
	}
}); 


$(function(){	
	$("#menubar").accordion({
		header: "h4",
		autoHeight: true,
		navigation: true
	});
});